/*
 * Copyright (C) 2011 CrystalRange
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.crystalrange.help.web;

import java.util.ArrayList;
import org.crystalrange.help.model.HelpFolder;
import org.crystalrange.help.service.HelpFolderService;
import org.crystalrange.help.service.HelpItemService;

public class HelpRootTreeNode extends TreeNode {

    private HelpFolderService helpFolderService;
    private HelpItemService helpItemService;

    public HelpFolderService getHelpFolderService() {
        return this.helpFolderService;
    }

    public void setHelpFolderService(HelpFolderService helpFolderService) {
        this.helpFolderService = helpFolderService;
    }

    public HelpItemService getHelpItemService() {
        return this.helpItemService;
    }

    public void setHelpItemService(HelpItemService helpItemService) {
        this.helpItemService = helpItemService;
    }

    @Override
    public void readChildren() {
        this.children = new ArrayList<TreeNode>();

        HelpFolder helpFolder = this.helpFolderService.find(new Long("1"));
        HelpFolderTreeNode helpFolderTreeNode = new HelpFolderTreeNode();
        helpFolderTreeNode.setHelpFolderService(this.helpFolderService);
        helpFolderTreeNode.setHelpItemService(this.helpItemService);
        helpFolderTreeNode.setId(helpFolder.getId());
        helpFolderTreeNode.setName(helpFolder.getName());
        helpFolderTreeNode.setDescription(helpFolder.getDescription());
        helpFolderTreeNode.setLocation(helpFolder.getLocation());
        this.children.add(helpFolderTreeNode);
    }

    @Override
    public boolean isLeaf() {
        return false;
    }
}
